package com.plant.college.controller;

import com.plant.college.domain.College;
import com.plant.college.service.CollegeService;
import com.plant.common.result.Result;
import com.plant.common.result.ResultCodeEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("college")
public class CollegeController {

    @Autowired
    CollegeService collegeService;
    @GetMapping("findByCollege")
    public Result getCollege(College college) {
     List<College> colleges = collegeService.getCollege(college);
     return Result.build(colleges,ResultCodeEnum.SUCCESS);
    }

    @GetMapping("findByIdCollege/{id}")
    public Result findByIdCollege(@PathVariable Integer id) {
     College college = collegeService.findByIdCollege(id);
     return Result.build(college,ResultCodeEnum.SUCCESS);
    }


}
